﻿@model ESN.Models.CustomProfile
@{
    ViewBag.Title = Model.UserName + " " + ViewBag.Home;
}
<script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
<script type="text/javascript">
    var UserName = "@Model.UserName";
    $(document).ready(function () {
        $("#makeFriend").button();
        $("#makeFriend").click(function () {
            if (typeof YourId == "undefined") {
                $("#requestArea").hide();
                $("#friendRequessNote").append("<b>@ViewBag.ShouldLoggin</b>");
            }
            $("#submitedDialog").dialog("open");
        });
        $("#dialog:ui-dialog").dialog("destroy");
        $("#submitedDialog").dialog({ autoOpen: false,
            modal: true,
            width: 400,
            maxWidth: "40%"
        });
        $("#attachmentForm").ajaxForm({
            iframe: true
        });
        $('.downloadAtt').live('click', function () {
            window.open($(this).attr('href'), "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=400, height=400");
            return false;
        });
    });
</script>
<script type="text/javascript" src="@Url.Content("~/Scripts/esnHome-wall.js")"></script>
<h2>@Html.DisplayFor(model => model.DisplayName)</h2>
<div>
    @if (ViewBag.ReadWall)
    {
    <div style="float: left; width : 520px; border-right : 1px dashed;">
        @if (ViewBag.PostWall)
        {
        <div id="loading"><img width="300" height="43" src="/Content/images/loading.gif" alt="loading..." /></div>
        <div id="wallPost">
            <textarea id="wallPostInput" cols="50" rows="2" style="width: 500px;"></textarea>
            <div id="wallPostTool">
                <form id="attachmentForm" action="/Home/UploadAttachment" method="post" enctype="multipart/form-data">
                    <input type="hidden" id="UserId" name="UserId" value="@Model.UserId" />
                    <input type="hidden" id="attPublic" name="isPublic" />
                    <input type="file" id="attContent" name="file" /><input type="button" id="noAttFile" value="@ViewBag.Cancel" />
                </form>
                <span>@ViewBag.PublicWall</span><input type="checkbox" id="wallPublic" />
                <input type="button" id="wallPostSend" value="@ViewBag.Save" />
                <a id="attFile">@ViewBag.AttFile</a>
            </div>
        </div>
        }
        else
        {
            <input type="hidden" id="UserId" name="UserId" value="@Model.UserId" />
        }
        <table id="wallMessContainer" class="ui-corner-all ui-widget-content">
        @foreach (var w in ViewBag.First20Walls)
        {
            <tr>
                <td class="wallLeftCol"><img width="40px" height="60px" src="@w.Writer.Avatar" alt="avatar" /></td>
                <td class="wallRightCol"><div class="wallContent">
                    <a href="/@w.Writer.UserName/Home"><b>@w.Writer.DisplayName</b></a>:@w.WContent</div>
                    @if (w.Attachments != null)
                    {
                        if (w.Attachments.isImage)
                        {
                            <div class="wallContent"><img width="450" src="@w.Attachments.ASource" alt="attachment" /></div>
                        }
                        else
                        {
                            <div class="wallContent"><a class="downloadAtt" href="/Home/DownloadAttachment/@w.Attachments.AId">@w.Attachments.AName</a></div>
                        }
                    }
                    @if (w.Children != null)
                    {
                        foreach (var c in w.Children)
                        {
                            <div class="wallComment ui-corner-right">
                                <img width="30px" height="45px" src="@c.Writer.Avatar" alt="avatar" />
                                <span class="wallCommentContent"><b><a href="/@c.Writer.UserName/Home">@c.Writer.DisplayName</a></b>:@c.WContent</span>
                            </div>
                        }
                    }
                    <div><textarea data-id="@w.WId" class="wallCommentInput" cols="40" rows="1" style="width: 400px;"></textarea></div>
                </td>
            </tr>
        }
        </table>
        <div id="lastMessage"><img width="300" height="43" src="/Content/images/loading.gif" alt="loading..." /></div>
    </div>
    }
    else
    {
        <input type="hidden" id="UserId" name="UserId" value="@Model.UserId" />
    }
    <div style="float: right; width: 200px;padding-right:10px;">
        @Html.Partial("_UserInfo", Model)
    </div>
</div>